package com.zzvcom.service.admin;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zzvcom.persist.model.admin.ProductPile;
import com.zzvcom.template.hibernate.DefaultManager;

@Service
@Transactional
public class ProductPileManager extends DefaultManager<ProductPile, String>
{

    @Transactional
    public void syncPile(String pile)
    {
        DetachedCriteria dc = DetachedCriteria.forClass(ProductPile.class);
        dc.add(Restrictions.eq("pile", pile));
        if (this.countByCriteria(dc) == 0)
        {
            ProductPile pz = new ProductPile();
            pz.setPile(pile);
            this.save(pz);
        }
    }

}
